/**
 * date:2019/08/16
 * author:Mr.Chung
 * description:此处放layui自定义扩展
 * version:2.0.4
 */

window.rootPath = (function (src) {
    src = document.scripts[document.scripts.length - 1].src;
    return src.substring(0, src.lastIndexOf("/") + 1);
})();

layui.config({
    base:getProjectUrl()+'plugs/',
    version: true,
}).extend({
    
    miniAdmin: "layuimini/miniAdmin", // layuimini后台扩展
    miniMenu: "layuimini/miniMenu", // layuimini菜单扩展
    miniTab: "layuimini/miniTab", // layuimini tab扩展
    miniTheme: "layuimini/miniTheme", // layuimini 主题扩展
    miniTongji: "layuimini/miniTongji", // layuimini 统计扩展
    step: 'step-lay/step', // 分步表单扩展
    treetable: 'treetable-lay/treetable', //table树形扩展
    tableSelect: 'tableSelect/tableSelect', // table选择扩展
    iconPickerFa: 'iconPicker/iconPickerFa', // fa图标选择扩展
    echarts: 'echarts/echarts', // echarts图表扩展
    echartsTheme: 'echarts/echartsTheme', // echarts图表主题扩展
    wangEditor: 'wangEditor/wangEditor', // wangEditor富文本扩展
    layarea: 'layarea/layarea', //  省市县区三级联动下拉选择器
    cascader:'lay_cascader/cascader/cascader'
});
/** 获取当前项目的根路径，通过获取layui.js全路径截取plugs之前的地址 */
function getProjectUrl() {
    var layuiDir = layui.cache.dir;
    if (!layuiDir) {
        var js = document.scripts, last = js.length - 1, src;
        for (var i = last; i > 0; i--) {
            if (js[i].readyState === 'interactive') {
                src = js[i].src;
                break;
            }
        }
        var jsPath = src || js[last].src;
        layuiDir = jsPath.substring(0, jsPath.lastIndexOf('/') + 1);
    }
    return layuiDir.substring(0, layuiDir.indexOf('plugs'));
}

var BASE_URL = document.scripts[document.scripts.length - 1].src.substring(0, document.scripts[document.scripts.length - 1].src.lastIndexOf("/") + 1);
var DOMAIN_URL = BASE_URL.replace('/static/admin/js', '');
BASE_URL=BASE_URL.replace('/admin/js','');
window.BASE_URL = BASE_URL.replace('js/admin/','');
// 路径配置信息
var PATH_CONFIG = {
    iconLess: BASE_URL + "/admin/plugs/font-awesome-4.7.0/less/variables.less",
};
window.PATH_CONFIG = PATH_CONFIG;

console.log(11111111111111111111)
console.log(CONFIG.CONTROLLER_JS_PATH)
// 初始化控制器对应的JS自动加载
if ("undefined" != typeof CONFIG.AUTOLOAD_JS && CONFIG.AUTOLOAD_JS) {
    require([BASE_URL + CONFIG.CONTROLLER_JS_PATH], function (Controller) {
        //  console.log('Controller.' + CONFIG.ACTION)
       if(CONFIG.ACTION){
           if (eval('Controller.' + CONFIG.ACTION)) {
               eval('Controller.' + CONFIG.ACTION + '()');
           }
       }
    });
}
require.config({
    urlArgs: "v=" + CONFIG.VERSION,
    baseUrl: getProjectUrl(),
    paths: {
        "dropzone": ["plugs/dropzone/dropzone-amd-module.min"],
        "admin_base": ["js/admin_base"],
        "tableSelect": ["plugs/tableSelect/tableSelect"],
        "jquery": ["plugs/jquery-3.4.1/jquery-3.4.1.min"],
        "ckeditor": ["plugs/ckeditor4/ckeditor"],
        "treetable": ["plugs/treetable-lay/treetable"],
        "tableSelect": ["plugs/tableSelect/tableSelect"],
        "iconPickerFa": ["plugs/iconPicker/iconPickerFa"],
        "autocomplete": ["plugs/autocomplete/autocomplete"],
        "vue": ["plugs/vue-2.6.10/vue"],
    
    }
});